package com.ruoyi.web.controller.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manipulatorServer.domain.Manipulator;
import com.ruoyi.manipulatorServer.service.IManipulatorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 飞手管理Controller
 * 
 * @author ruoyi
 * @date 2025-05-21
 */
@RestController
@RequestMapping("/manipulater-server/manipulator")
public class ManipulatorController extends BaseController
{
    @Autowired
    private IManipulatorService manipulatorService;

    /**
     * 查询飞手管理列表
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:list')")
    @GetMapping("/list")
    public TableDataInfo list(Manipulator manipulator)
    {
        startPage();
        List<Manipulator> list = manipulatorService.selectManipulatorList(manipulator);
        return getDataTable(list);
    }

    /**
     * 导出飞手管理列表
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:export')")
    @Log(title = "飞手管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Manipulator manipulator)
    {
        List<Manipulator> list = manipulatorService.selectManipulatorList(manipulator);
        ExcelUtil<Manipulator> util = new ExcelUtil<Manipulator>(Manipulator.class);
        util.exportExcel(response, list, "飞手管理数据");
    }

    /**
     * 获取飞手管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(manipulatorService.selectManipulatorById(id));
    }

    /**
     * 新增飞手管理
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:add')")
    @Log(title = "飞手管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Manipulator manipulator)
    {
        return toAjax(manipulatorService.insertManipulator(manipulator));
    }

    /**
     * 修改飞手管理
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:edit')")
    @Log(title = "飞手管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Manipulator manipulator)
    {
        return toAjax(manipulatorService.updateManipulator(manipulator));
    }

    /**
     * 删除飞手管理
     */
    @PreAuthorize("@ss.hasPermi('manipulater-server:manipulator:remove')")
    @Log(title = "飞手管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(manipulatorService.deleteManipulatorByIds(ids));
    }
}
